import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';
import p001 from "./p001";
import p002 from "./p002";
import p003 from "./p003";
import p004 from "./p004";
export default async function a001(fd: IFeidaoAiBrowserComponent) {
	// todo //打开引用公司弹窗
	const d = fd.data.node.querySelector<HTMLDivElement>('[data-yy="gsyy_window"]');
	set_node_cls(d, 'display-n', false);

	const page_no = fd.data.params['page-n'] as string;
	let page = 1;
	if (page_no) {
		page = parseInt(page_no, 10);
	}

	const high_company_name = fd.data.node.querySelector<HTMLInputElement>('[data-id="sjqymx"]').value;
	const res = await nodejs<{ res: Array<{}>, t: number }>('company-factory/zj-000006/s001',
		{
			high_company_name: { $like: '%' + high_company_name + '%' },
			page_no: page
		});
	if (res.res.length > 0) {
		render(fd, res.res, p001, 'p001', "inner");
		render(fd, res.t, p003, 'p003', "inner");
	} else {
		render(fd, '', p002, 'p001', "inner");
		render(fd, '', p004, 'p003', "inner");
	}


}
